import React, { useState, useRef, useEffect } from 'react';
import {
  Form,
  FormItem,
  FormPath,
  setValidationLocale,
  registerValidationRules,
  registerValidationFormats,
  registerValidationMTEngine,
} from '@formily/antd';
// eslint-disable-next-line import/no-named-default
import { default as CG } from '@/components/ComboGrid';

// setValidationLocale({
//   zh: {
//     required: '这是定制必填文案',
//     custom_format: '必须是数字  <% injectVar %>',
//   },
// });

// registerValidationRules({
//   customRule: value => {
//     return value === '123' ? '不能等于123' : '';
//   },
// });

function ComboGrid({ disabled = false, placeholder = '请选择', onChange, value }) {
  return (
    <>
      <CG
        url="formDesigner/selectSystemRolesGridData.do"
        value={Array.isArray(value) ? value : []}
        popupStyle={{ width: 600 }}
        placeholder={placeholder}
        searchPlaceholder="处理人名称"
        destroyPopupOnHide
        label="roleName"
        disabled={disabled}
        rowKey="id"
        columns={[
          {
            title: '处理人',
            dataIndex: 'dealerName',
            ellipsis: true,
          },
          {
            title: '角色名称',
            dataIndex: 'roleName',
            ellipsis: true,
          },
          {
            title: '所属部门',
            align: 'center',
            dataIndex: 'department',
          },
        ]}
        onConfirm={selectedRows => {
          onChange(selectedRows);
        }}
      />
    </>
  );
}

ComboGrid.defaultProps = {};

ComboGrid.propTypes = {};

export default ComboGrid;
